<template>
    <div>
      <el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
    </div>
</template>

<script>
    export default {
      data() {
        return {
          data:[],
          defaultProps: {
            children: 'children',
            label: 'name'
          },
        }
      },
      methods: {
        handleNodeClick(data,node,self) {
          this.$emit("tree-node-click",data,node,self)
        },
        // 获取树形结构商品分类信息
        getProductTree() {
          this.$http({
            url: this.$http.adornUrl('/product/product/category/list/tree'),
            method: 'get',
          }).then(({data}) => {
            if (data && data.code === 0) {
              this.data = data.list
            }
          })
        },
      },
      created(){
        this.getProductTree()
      }

    }
</script>

<style scoped>

</style>
